package my.interview;

import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;

/**
 * @DESCRIPTION:
 * @USER: shg
 * @DATE: 2022/12/25 18:14
 */
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        String[] temp = str.split(" ");
        Arrays.sort(temp);
        TreeSet<String> treeSet = new TreeSet<>(Arrays.asList(temp));

        for (int i = temp.length - 1; i >= 0; i--) {
            String pw = temp[i];
            String substring = pw.substring(0, pw.length() - 1);
            boolean flag = true;
            while (substring.length() > 0) {
                if (flag = treeSet.contains(substring)) {
                    substring = substring.substring(0, substring.length() - 1);
                } else {
                    break;
                }
            }
            if (flag) {
                System.out.println(pw);
            }
        }
        System.out.println("");
    }
}
